<?php
/**
 * @Name  : NodeSaveRequest.php
 * @Author: yashuai<1762910894@qq.com>
 * @Desc  : 添加编辑菜单
 */

namespace App\Http\Requests\Rbac;

use Illuminate\Validation\Rule;
use App\Http\Requests\PackingRequest;
use HugCode\PhpUnits\Frame\Code\ConstCode;

class NodeSaveRequest extends PackingRequest
{

    public function rules()
    {
        return [
            'NodeName'       => 'required|max:50',
            'ParentID'       => 'integer',
            'ControllerName' => 'required|max:50',
            'ActionName'     => 'required|max:50',
            'NodeType'       => Rule::in(array_keys(ConstCode::NODE_TYPE)),
            'NodeShowType'   => Rule::in(array_keys(ConstCode::BOOL)),
            'NodeOrder'      => 'required|integer',
        ];
    }

    public function messages()
    {
        return [
            'NodeID.required'         => '缺少记录ID参数',
            'NodeID.integer'          => '记录ID参数类型异常',
            'NodeName.required'       => '请输入菜单名称',
            'NodeName.max'            => '菜单名称过长',
            'ParentID.integer'        => '上级菜单类型异常',
            'ControllerName.required' => '请输入控制器名称',
            'ControllerName.max'      => '控制器名称过长',
            'ActionName.required'     => '请输入方法名称',
            'ActionName.max'          => '方法名称过长',
            'NodeType.in'             => '菜单类型不在范围内',
            'NodeShowType.in'         => '菜单是否显示不在范围内',
            'NodeOrder.required'      => '请输入序号',
            'NodeOrder.integer'       => '序号类型异常',
        ];
    }

}
